package com.study.testSpringBoot.service.impl;

import java.util.concurrent.atomic.AtomicInteger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.study.testSpringBoot.concurrent.DataModel;
import com.study.testSpringBoot.concurrent.DataModelAtomic;
import com.study.testSpringBoot.concurrent.DataModelLock;
import com.study.testSpringBoot.service.IProviderService;

/**
 * 生成数据service
 */
@Service
public class ProviderServiceImpl implements IProviderService {

	@Autowired
	private DataModel dataModel;
	
	@Autowired
	private DataModelLock dataModelLock;
	
	@Autowired
	private DataModelAtomic dataModelAtomic;
	
	private AtomicInteger result = new AtomicInteger(0);
	
	/**
	 * 生成数据
	 */
	@Override
	public void provideData() {
		result.incrementAndGet();
		dataModel.addData("ceshi");
//		dataModelLock.addData("ceshi");
//		dataModelAtomic.addData("ceshi");
	}

	public AtomicInteger getResult() {
		return result;
	}
	
}
